<template>
  <div class="page-container">
    <!--工具栏-->
    <div class="toolbar" style="padding-top:10px;">
      <el-form :inline="true" :model="filters" ref="filters" :size="size" label-width="120px">
        <el-form-item prop="name" label="门店名称">
          <el-input v-model="filters.name" placeholder="门店名称"></el-input>
        </el-form-item>
        <el-form-item prop="legal_name" label="法人名称">
          <el-input
            v-model="filters.legal_name"
            placeholder="法人姓名"
          ></el-input>
        </el-form-item>
        <el-form-item prop="type" label="选择店铺名称">
          <el-select v-model="filters.type">
            <el-option label="请选择店铺类型" value></el-option>
            <el-option
              v-for="item in type"
              :key="item.key"
              :label="item.value"
              :value="item.key"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-row>
          <el-form-item>
          <kt-button
            icon="fa fa-search"
            :label="$t('action.search')"
            type="primary"
            @click="findPage(null)"
          />
        </el-form-item>
        <el-form-item>
          <kt-button
            icon="fa fa-plus"
            :label="$t('action.add')"
            type="primary"
            @click="handleAdd"
          />
        </el-form-item>
        <el-form-item>
          <kt-button
            icon="fa fa-refresh" :label="$t('action.reset')"
            type="primary"
            @click="resetForm('filters')"
          />
        </el-form-item>
        <el-form-item>
          <kt-button label="库存设置" type="primary" @click="setStock()" />
        </el-form-item>
        <el-form-item>
          <kt-button
            label="营业时间设置"
            type="primary"
            @click="setShopBusinessTime()"
          />
        </el-form-item>
        <el-form-item style="float:right">
          <el-button-group>
            <el-tooltip content="刷新" placement="top">
              <el-button
                icon="fa fa-refresh"
                @click="findPage(null)"
              ></el-button>
            </el-tooltip>
            <el-tooltip content="列显示" placement="top">
              <el-button
                icon="fa fa-filter"
                @click="displayFilterColumnsDialog"
              ></el-button>
            </el-tooltip>
            <el-tooltip content="导出" placement="top">
              <el-button
                icon="fa fa-file-excel-o"
                @click="downloadExcel"
                id="downloadExcel"
              ></el-button>
            </el-tooltip>
          </el-button-group>
        </el-form-item>
        </el-row>
      </el-form>
    </div>
    <div
      class="toolbar"
      style="float:right;padding-top:10px;padding-right:15px;">
      <!--表格显示列界面-->
      <table-column-filter-dialog
        ref="tableColumnFilterDialog"
        :columns="columns"
        @handleFilterColumns="handleFilterColumns"
      ></table-column-filter-dialog>
    </div>
    <!--表格内容栏-->
    <cy-table
      :height="350"
      :data="pageResult"
      :columns="filterColumns"
      @selectionChange="selectionChange"
      @findPage="findPage"
      @handleEdit="handleEdit"
      @handleDelete="handleDelete"
      ref="CyTable"
    ></cy-table>
    <!--新增编辑界面-->
    <el-dialog
      :title="operation ? '新增' : '编辑'"
      width="80%"
      :visible.sync="dialogVisible"
      :close-on-click-modal="false"
    >
      <el-form
        :model="dataForm"
        :inline="true"
        label-width="80px"
        :rules="dataFormRules"
        ref="dataForm"
        :size="size"
        label-position="right"
      >
        <el-form-item label="ID" prop="id" v-if="false">
          <el-input
            v-model="dataForm.id"
            :disabled="true"
            auto-complete="off"
          ></el-input>
        </el-form-item>
        <el-form-item label="店铺名称" prop="name">
          <el-input v-model="dataForm.name" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item label="店铺地址" prop="address">
          <el-input v-model="dataForm.address" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item label="提现比例" prop="withd_proport">
          <el-input
            v-model="dataForm.withd_proport"
            auto-complete="off"
          ></el-input>
        </el-form-item>
        <el-form-item label="LBS服务范围(公里)" prop="service_range">
          <el-input
            v-model="dataForm.service_range"
            auto-complete="off"
          ></el-input>
        </el-form-item>
        <el-form-item label="店铺类别" prop="type">
          <el-select v-model="dataForm.type" style="width: 200px">
            <el-option label="请选择" value></el-option>
            <el-option
              v-for="item in type"
              :key="item.key"
              :label="item.value"
              :value="item.key"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="营业执照编号" prop="license_number">
          <el-input
            v-model="dataForm.license_number"
            auto-complete="off"
          ></el-input>
        </el-form-item>
        <el-form-item label="法人姓名" prop="legal_name">
          <el-input
            v-model="dataForm.legal_name"
            auto-complete="off"
          ></el-input>
        </el-form-item>
        <el-form-item label="法人身份证" prop="legal_number">
          <el-input
            v-model="dataForm.legal_number"
            auto-complete="off"
          ></el-input>
        </el-form-item>
        <el-form-item label="注册资本(万)" prop="register_capital">
          <el-input
            v-model="dataForm.register_capital"
            auto-complete="off"
          ></el-input>
        </el-form-item>
        <el-form-item label="经营范围" prop="scope">
          <el-input v-model="dataForm.scope" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item label="对公账户名称" prop="account_name">
          <el-input
            v-model="dataForm.account_name"
            auto-complete="off"
          ></el-input>
        </el-form-item>

        <el-form-item label="对公账户账号" prop="account_number">
          <el-input
            v-model="dataForm.account_number"
            auto-complete="off"
          ></el-input>
        </el-form-item>
        <el-form-item label="账号开户地址" prop="account_address">
          <el-input
            v-model="dataForm.account_address"
            auto-complete="off"
          ></el-input>
        </el-form-item>
        <el-form-item label="状态" prop="status">
          <el-select v-model="dataForm.status" style="width: 200px">
            <el-option label="请选择" value></el-option>
            <el-option
              v-for="item in list"
              :key="item.id"
              :label="item.val"
              :value="item.id"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="保证金" prop="bail">
          <el-input v-model="dataForm.bail" auto-complete="off"></el-input>
        </el-form-item>

        <el-form-item label="是否缴纳" prop="bail_flag">
          <el-select v-model="dataForm.bail_flag" style="width: 200px">
            <el-option label="请选择" value></el-option>
            <el-option
              v-for="item in bail_flag"
              :key="item.key"
              :label="item.value"
              :value="item.key"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="营业时间" prop="opentime">
          <el-input v-model="dataForm.opentime" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item label="纬度" prop="latitude">
          <el-input v-model="dataForm.latitude" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item label="经度" prop="longitude">
          <el-input v-model="dataForm.longitude" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item label="商铺联系电话" prop="mobile">
          <el-input v-model="dataForm.mobile" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item label="联系人" prop="contact_person">
          <el-input
            v-model="dataForm.contact_person"
            auto-complete="off"
          ></el-input>
        </el-form-item>
        <el-form-item label="店铺模板地址" prop="shop_address">
          <el-input
            v-model="dataForm.shop_address"
            auto-complete="off"
          ></el-input>
        </el-form-item>
        <el-form-item label="商铺邮箱" prop="email">
          <el-input v-model="dataForm.email" auto-complete="off"></el-input>
        </el-form-item>
        <el-row>
          <el-form-item label="店铺图片" prop="business_license">
            <el-upload
              :action="imgUpload"
              :on-success="handleAvatarSuccess"
              list-type="picture-card"
              v-model="dataForm.pic"
              accept="image/gif, image/jpeg, image/jpg, image/png, image/svg"
              :on-preview="handlePictureCardPreview"
              :on-remove="handleRemove"
              :limit="3"
              style="float:left"
              ref="shop_upload"
              :file-list="shopImgList"
            >
              <i class="el-icon-plus"></i>
            </el-upload>
          </el-form-item>
          <el-form-item label="法人身份证正面" prop="business_license">
            <el-upload
              :action="imgUpload"
              :on-success="handleAvatarSuccess1"
              list-type="picture-card"
              v-model="dataForm.id_card_z"
              accept="image/gif, image/jpeg, image/jpg, image/png, image/svg"
              :on-preview="handlePictureCardPreview1"
              :on-remove="handleRemove1"
              :limit="3"
              style="float:left"
              ref="id_card_z_upload"
              :file-list="idCardZImgList"
            >
              <i class="el-icon-plus"></i>
            </el-upload>
          </el-form-item>

          <el-form-item label="法人身份证反面" prop="business_license">
            <el-upload
              :action="imgUpload"
              :on-success="handleAvatarSuccess2"
              list-type="picture-card"
              v-model="dataForm.id_card_f"
              accept="image/gif, image/jpeg, image/jpg, image/png, image/svg"
              :on-preview="handlePictureCardPreview2"
              :on-remove="handleRemove2"
              :limit="3"
              style="float:left"
              ref="id_card_f_upload"
              :file-list="idCardFImgList"
            >
              <i class="el-icon-plus"></i>
            </el-upload>
          </el-form-item>
          <el-form-item label="营业执照" prop="business_license">
            <el-upload
              :action="imgUpload"
              :on-success="handleAvatarSuccess3"
              list-type="picture-card"
              v-model="dataForm.business_license"
              accept="image/gif, image/jpeg, image/jpg, image/png, image/svg"
              :on-preview="handlePictureCardPreview3"
              :on-remove="handleRemove3"
              :limit="3"
              style="float:left"
              ref="business_license_upload"
              :file-list="businessLicenseImgList"
            >
              <i class="el-icon-plus"></i>
            </el-upload>
          </el-form-item>
          <el-form-item label="食品安全证明" prop="business_license">
            <el-upload
              :action="imgUpload"
              :on-success="handleAvatarSuccess4"
              list-type="picture-card"
              v-model="dataForm.food_safety"
              accept="image/gif, image/jpeg, image/jpg, image/png, image/svg"
              :on-preview="handlePictureCardPreview4"
              :on-remove="handleRemove4"
              :limit="3"
              style="float:left"
              ref="food_safety_upload"
              :file-list="foodSafetyImgList"
            >
              <i class="el-icon-plus"></i>
            </el-upload>
          </el-form-item>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer" style="text-align:center">
        <el-button :size="size" @click="cleanDataForm">{{
          $t("action.cancel")
        }}</el-button>
        <el-button
          :size="size"
          type="primary"
          @click.native="submitForm"
          :loading="editLoading"
          >{{ $t("action.submit") }}</el-button
        >
      </div>
    </el-dialog>

    <!--新增编辑界面-->
    <el-dialog
      title="营业时间配置"
      width="60%"
      :visible.sync="dialogVisibleOpenTime"
      :close-on-click-modal="false"
    >
      <el-form
        :model="dataFormOpenTime"
        :inline="true"
        label-width="80px"
        :rules="dataFormOpenTimeRules"
        ref="dataFormOpenTime"
        :size="size"
        label-position="right"
      >
        <el-form-item label="ID" prop="id" v-if="false">
          <el-input
            v-model="dataFormOpenTime.id"
            :disabled="true"
            auto-complete="off"
          ></el-input>
        </el-form-item>
        <el-form-item label="开始时间" prop="open_start_time">
          <el-time-select
            v-model="dataFormOpenTime.open_start_time"
            :picker-options="{
              start: '00:00',
              step: '00:30',
              end: '24:00'
            }"
            placeholder="选择时间"
          ></el-time-select>
        </el-form-item>
        <el-form-item label="结束时间" prop="open_end_time">
          <el-time-select
            v-model="dataFormOpenTime.open_end_time"
            :picker-options="{
              start: '00:00',
              step: '00:30',
              end: '24:00'
            }"
            placeholder="选择时间"
          ></el-time-select>
        </el-form-item>
        <el-form-item label="营业时间描述" prop="opentime">
          <el-input
            v-model="dataFormOpenTime.opentime"
            auto-complete="off"
          ></el-input>
        </el-form-item>
        <el-form-item label="纬度" prop="latitude">
          <el-input
            v-model="dataFormOpenTime.latitude"
            auto-complete="off"
          ></el-input>
        </el-form-item>
        <el-form-item label="经度" prop="longitude">
          <el-input
            v-model="dataFormOpenTime.longitude"
            auto-complete="off"
          ></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer" style="text-align:center">
        <el-button :size="size" @click.native="dialogVisibleOpenTime = false">{{
          $t("action.cancel")
        }}</el-button>
        <el-button
          :size="size"
          type="primary"
          @click="submitFormOpentime"
          :loading="editLoading"
          >{{ $t("action.submit") }}</el-button
        >
      </div>
    </el-dialog>
  </div>
</template>

<script>
import PopupTreeInput from "@/components/PopupTreeInput";
import CyTable from "@/views/Core/CyTable";
import KtButton from "@/views/Core/KtButton";
import TableColumnFilterDialog from "@/views/Core/TableColumnFilterDialog";
import { format } from "@/utils/datetime";
import utils from "@/assets/js/utils.js";
export default {
  components: {
    PopupTreeInput,
    CyTable,
    KtButton,
    TableColumnFilterDialog
  },
  data() {
    return {
      imgUpload: this.utils.getUpLoadHostForImg(),
      shopImgList: [],
      idCardFImgList: [],
      idCardZImgList: [],
      businessLicenseImgList: [],
      foodSafetyImgList: [],
      size: "small",
      list: [],
      shoplist: [],
      type: [{ key: "0", value: "自营" }, { key: "1", value: "私营" }],
      bail_flag: [{ key: "Y", value: "是" }, { key: "N", value: "否" }],
      filters: {
        name: "",
        type: "",
        legal_name: "",
        t: "shop"
      },
      columns: [],
      checked: [],
      filterColumns: [],
      pageRequest: { pageNum: 1, pageSize: 10 },
      pageResult: {},

      operation: false, // true:新增, false:编辑
      dialogVisible: false, // 新增编辑界面是否显示
      dialogVisibleOpenTime: false, //营业时间是否显示
      editLoading: false,
      dataFormRules: {
        // service_range: [
        // 	{ required: true, validator: checkAge,message: '请仓库属性', trigger: 'blur' }
        // ]
      },
      dataFormOpenTimeRules: {
        open_start_time: [
          { required: true, message: "请输入开始时间", trigger: "blur" }
        ],
        open_end_time: [
          { required: true, message: "请输入结束时间", trigger: "blur" }
        ]
      },
      // 新增编辑界面数据
      dataForm: {
        name: "",
        address: "",
        type: "",
        pic: "",
        license_number: "",
        legal_name: "",
        legal_number: "",
        register_capital: "",
        scope: "",
        account_name: "",
        account_number: "",
        account_address: "",
        bail: "",
        bail_flag: "",
        mobile: "",
        pro_evaluate: "",
        server_evaluate: "",
        tms_evaluate: "",
        pro_industry: "",
        server_industry: "",
        tms_industry: "",
        status: "",
        withd_proport: "",
        service_range: "",
        id_card_z: "",
        id_card_f: "",
        food_safety: "",
        shop_address: "",
        contact_person: "",
        email: "",
        opentime: "",
        longitude: "",
        latitude: "",
        business_license: ""
      },
      // 营业时间设置
      dataFormOpenTime: {
        opentime: "",
        longitude: "",
        latitude: "",
        longitude: "",
        open_start_time: "",
        open_end_time: ""
      }
    };
  },

  methods: {
    // 获取分页数据
    findPage: function(data) {
      this.$refs.CyTable.findPage(this.filters);
    },
    // 门店状态初始化
    queryUserList() {
      var that = this;
      this.utils.request.queryUserList(
        { t: "sysConfig", type: "shop_status" },
        function(data) {
          that.list = data.data;
        }
      );
    },

    // 批量删除
    handleDelete: function(data) {
      var ids = "";
      for (var i = 0; i < data.params.length; i++) {
        ids = ids + data.params[i].id + ",";
      }
      data.t = "shop";
      data.ids = ids;
      this.utils.request.deleteUserInfo(data, data.callback);
    },
    //列表下载
    downloadExcel() {
      this.$confirm("确定下载列表文件?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          let filename = "店铺信息";
          this.$refs.CyTable.exportData(
            this.filters,
            this.filterColumns,
            filename
          );
        })
        .catch(() => {});
    },
    // 显示新增界面
    handleAdd: function() {
      let this_ = this;
      this.dialogVisible = true;
      this.operation = true;
      this.dataForm = {
        name: "",
        address: "",
        type: "",
        pic: "",
        license_number: "",
        legal_name: "",
        legal_number: "",
        register_capital: "",
        scope: "",
        account_name: "",
        account_number: "",
        account_address: "",
        bail: "",
        bail_flag: "",
        mobile: "",
        pro_evaluate: "",
        server_evaluate: "",
        tms_evaluate: "",
        pro_industry: "",
        server_industry: "",
        tms_industry: "",
        status: "",
        withd_proport: "",
        service_range: "",
        id_card_z: "",
        id_card_f: "",
        food_safety: "",
        shop_address: "",
        contact_person: "",
        email: "",
        opentime: "",
        longitude: "",
        latitude: "",
        business_license: ""
      };
    },
    // 显示编辑界面
    handleEdit: function(params) {
      this.dialogVisible = true;
      this.operation = false;
      this.dataForm = Object.assign({}, params.row);
      let shop = params.row.pic.split(","); //店铺图片
      let shopImg = {};
      for (let i = 0; i < shop.length; i++) {
        if (shop[i] != "") {
          shopImg.name = i;
          shopImg.url = shop[i];
          this.shopImgList.push(shopImg);
          break;
        }
      }

      let idCardZ = params.row.id_card_z.split(","); //身份证正面图片
      let idCardZImg = {};
      for (let i = 0; i < idCardZ.length; i++) {
        if (idCardZ[i] != "") {
          idCardZImg.name = i;
          idCardZImg.url = idCardZ[i];
          this.idCardZImgList.push(idCardZImg);
          break;
        }
      }

      let idCardF = params.row.id_card_f.split(","); //身份证反面图片
      let idCardFImg = {};
      for (let i = 0; i < idCardF.length; i++) {
        if (idCardF[i] != "") {
          idCardFImg.name = i;
          idCardFImg.url = idCardF[i];
          this.idCardFImgList.push(idCardFImg);
          break;
        }
      }

      let foodSafety = params.row.food_safety.split(","); //食品安全照片
      let foodSafetyImg = {};
      for (let i = 0; i < foodSafety.length; i++) {
        if (foodSafety[i] != "") {
          foodSafetyImg.name = i;
          foodSafetyImg.url = foodSafety[i];
          this.foodSafetyImgList.push(foodSafetyImg);
          break;
        }
      }

      let businessLicense = params.row.business_license.split(","); //食品安全照片
      let businessLicenseImg = {};
      for (let i = 0; i < businessLicense.length; i++) {
        if (businessLicense[i] != "") {
          businessLicenseImg.name = i;
          businessLicenseImg.url = businessLicense[i];
          this.businessLicenseImgList.push(businessLicenseImg);
          break;
        }
      }
    },
    // 编辑
    submitForm: function() {
      this.$refs.dataForm.validate(valid => {
        if (valid) {
          this.$confirm("确认提交吗？", "提示", {}).then(() => {
            this.editLoading = true;
            let params = Object.assign({}, this.dataForm);
            params.t = "shop";
            this.utils.request.editUserInfo(params, this.editInfoBack);
          });
        }
      });
    },
    // 新增修改回调
    editInfoBack: function(data) {
      if (data.code == "0000") {
        this.$message({ message: "操作成功", type: "success" });
        this.dialogVisible = false;
        this.$refs["dataForm"].resetFields();
      } else {
        this.$message({ message: "操作失败, " + data.msg, type: "error" });
      }
      this.findPage({ t: "shop" });
      this.dialogVisible = false;
      this.operation = false;
      this.editLoading = false;
      this.$refs["shop_upload"].clearFiles();
      this.$refs["id_card_z_upload"].clearFiles();
      this.$refs["id_card_f_upload"].clearFiles();
      this.$refs["food_safety_upload"].clearFiles();
      this.$refs["business_license_upload"].clearFiles();
    },
    // 时间格式化
    dateFormat: function(row, column, cellValue, index) {
      return format(row[column.property]);
    },
    // 处理表格列过滤显示
    displayFilterColumnsDialog: function() {
      this.$refs.tableColumnFilterDialog.setDialogVisible(true);
    },
    // 处理表格列过滤显示
    handleFilterColumns: function(data) {
      this.filterColumns = data.filterColumns;
      this.$refs.tableColumnFilterDialog.setDialogVisible(false);
    },
    // 处理表格列过滤显示
    initColumns: function() {
      this.columns = [
        { prop: "name", label: "店铺名称", minWidth: 120 },
        { prop: "address", label: "店铺地址", minWidth: 120 },
        {
          prop: "type",
          label: "店铺类别",
          minWidth: 120,
          formatter: this.shopType
        },
        { prop: "license_number", label: "营业执照编号", minWidth: 150 },
        { prop: "legal_name", label: "法人姓名", minWidth: 120 },
        { prop: "register_capital", label: "注册资本", minWidth: 120 },
        { prop: "scope", label: "经营范围", minWidth: 120 },
        { prop: "withd_proport", label: "提现比例", minWidth: 120 },
        { prop: "account_name", label: "对公账户名称", minWidth: 150 },
        { prop: "account_number", label: "对公账户账号", minWidth: 150 },
        { prop: "account_address", label: "账号开户地址", minWidth: 150 },
        { prop: "bail", label: "保证金", minWidth: 120 },
        {
          prop: "bail_flag",
          label: "是否缴纳",
          minWidth: 120,
          formatter: this.bailFlag
        },
        { prop: "mobile", label: "商铺联系电话", minWidth: 150 },
        { prop: "pro_evaluate", label: "商品评价", minWidth: 120 },
        { prop: "server_evaluate", label: "服务态度", minWidth: 120 },
        { prop: "tms_evaluate", label: "物流评分", minWidth: 120 },
        { prop: "pro_industry", label: "同行业相比(商品评价)", minWidth: 200 },
        {
          prop: "server_industry",
          label: "同行业相比(服务态度)",
          minWidth: 200
        },
        { prop: "tms_industry", label: "同行业相比(物流评分)", minWidth: 200 },
        { prop: "longitude", label: "纬度", minWidth: 150 },
        { prop: "latitude", label: "经度", minWidth: 150 },
        { prop: "statusval", label: "状态", minWidth: 120 },
        { prop: "service_range", label: "服务范围", minWidth: 120 },
        { prop: "shop_address", label: "店铺模板地址", minWidth: 150 },
        { prop: "contact_person", label: "联系人", minWidth: 120 },
        { prop: "email", label: "商铺邮箱", minWidth: 120 },
        { prop: "opentime", label: "营业时间", minWidth: 120 }
      ];
      var temp = [];
      $.each(this.columns, function(key, val) {
        temp.push(val);
      });
      this.filterColumns = temp;
    },
    //重置
    resetForm(formName) {
      this.$refs[formName].resetFields();
      this.findPage({ t: "shop" });
    },

    shopType(row, column, cellValue, index) {
      if (cellValue == "0") {
        return "自营";
      } else if (cellValue == "1") {
        return "私营";
      } else {
        return "未知";
      }
    },
    bailFlag(row, column, cellValue, index) {
      if (cellValue == "Y") {
        return "是";
      } else if (cellValue == "N") {
        return "否";
      } else {
        return "未知";
      }
    },
    // 门店营业时间设置
    //选择框
    selectionChange: function(params) {
      this.checked = params.selections;
    },

    setShopBusinessTime() {
      if (this.checked.length == 1) {
        this.dialogVisibleOpenTime = true;
        this.dataFormOpenTime.id = this.checked[0].id;
        this.dataFormOpenTime.open_start_time = this.checked[0].open_start_time;
        this.dataFormOpenTime.open_end_time = this.checked[0].open_end_time;
        this.dataFormOpenTime.opentime = this.checked[0].opentime;
        this.dataFormOpenTime.longitude = this.checked[0].longitude;
        this.dataFormOpenTime.latitude = this.checked[0].latitude;
        this.shopImgList = [];
        this.idCardFImgList = [];
        this.idCardZImgList = [];
        this.businessLicenseImgList = [];
        this.foodSafetyImgList = [];
      } else {
        this.$message({ message: "设置时只能选择一条数据", type: "error" });
      }
    },
    submitFormOpentime() {
      this.$refs.dataFormOpenTime.validate(valid => {
        if (valid) {
          this.$confirm("确认提交吗？", "提示", {}).then(() => {
            this.editLoading = true;
            let params = Object.assign({}, this.dataFormOpenTime);
            params.t = "shop";
            this.utils.request.editUserInfo(params, this.editInfoOpenTimeBack);
          });
        }
      });
    },
    // 新增修改回调
    editInfoOpenTimeBack: function(data) {
      if (data.code == "0000") {
        this.$message({ message: "操作成功", type: "success" });
        this.dialogVisibleOpenTime = false;
        this.editLoading = false;
      } else {
        this.$message({ message: "操作失败, " + data.msg, type: "error" });
      }
      this.findPage({ t: "shop" });
    },
    //店铺照片上传
    handleAvatarSuccess(res, file) {
      if (res.data.imgUrl == "") {
        this.$message({ message: "上传失败", type: "error" });
      } else {
        this.dataForm.pic += res.data.imgUrl + ",";
        this.imageUrl = URL.createObjectURL(file.raw);
      }
    },
    handlePictureCardPreview(file) {
      this.dialogImageUrl = file.url;
      this.ImageUrl = file.url;
      this.dialogVisibleImage = true;
    },
    handleRemove(file, fileList, index) {
      if (this.utils.isNull(index)) {
        this.fileList = fileList;
        if (fileList.length == 0) {
          this.dataForm.pic = "";
        } else {
          this.imgs = fileList
            .map(item => item.response.data.imgUrl)
            .toString();
          this.dataForm.pic = this.imgs;
        }
      } else {
        this.pic.splice(index, 1);
      }
    },

    //法人身份证正面上传
    handleAvatarSuccess1(res, file) {
      if (res.data.imgUrl == "") {
        this.$message({ message: "上传失败", type: "error" });
      } else {
        this.dataForm.id_card_z += res.data.imgUrl + ",";
        this.imageUrl = URL.createObjectURL(file.raw);
      }
    },
    handlePictureCardPreview1(file) {
      this.dialogImageUrl = file.url;
      this.ImageUrl = file.url;
      this.dialogVisibleImage = true;
    },
    handleRemove1(file, fileList, index) {
      if (this.utils.isNull(index)) {
        this.fileList = fileList;
        if (fileList.length == 0) {
          this.dataForm.id_card_z = "";
        } else {
          this.imgs = fileList
            .map(item => item.response.data.imgUrl)
            .toString();
          this.dataForm.id_card_z = this.imgs;
        }
      } else {
        this.id_card_z.splice(index, 1);
      }
    },

    //法人身份证反面上传
    handleAvatarSuccess2(res, file) {
      if (res.data.imgUrl == "") {
        this.$message({ message: "上传失败", type: "error" });
      } else {
        this.dataForm.id_card_f += res.data.imgUrl + ",";
        this.imageUrl = URL.createObjectURL(file.raw);
      }
    },
    handlePictureCardPreview2(file) {
      this.dialogImageUrl = file.url;
      this.ImageUrl = file.url;
      this.dialogVisibleImage = true;
    },
    handleRemove2(file, fileList, index) {
      if (this.utils.isNull(index)) {
        this.fileList = fileList;
        if (fileList.length == 0) {
          this.dataForm.id_card_f = "";
        } else {
          this.imgs = fileList
            .map(item => item.response.data.imgUrl)
            .toString();
          this.dataForm.id_card_f = this.imgs;
        }
      } else {
        this.id_card_f.splice(index, 1);
      }
    },

    //食品安全证明上传
    handleAvatarSuccess3(res, file) {
      if (res.data.imgUrl == "") {
        this.$message({ message: "上传失败", type: "error" });
      } else {
        this.dataForm.food_safety += res.data.imgUrl + ",";
        this.imageUrl = URL.createObjectURL(file.raw);
      }
    },
    handlePictureCardPreview3(file) {
      this.dialogImageUrl = file.url;
      this.ImageUrl = file.url;
      this.dialogVisibleImage = true;
    },
    handleRemove3(file, fileList, index) {
      if (this.utils.isNull(index)) {
        this.fileList = fileList;
        if (fileList.length == 0) {
          this.dataForm.food_safety = "";
        } else {
          this.imgs = fileList
            .map(item => item.response.data.imgUrl)
            .toString();
          this.dataForm.food_safety = this.imgs;
        }
      } else {
        this.food_safety.splice(index, 1);
      }
    },

    //营业执照上传
    handleAvatarSuccess4(res, file) {
      if (res.data.imgUrl == "") {
        this.$message({ message: "上传失败", type: "error" });
      } else {
        this.dataForm.business_license += res.data.imgUrl + ",";
        this.imageUrl = URL.createObjectURL(file.raw);
      }
    },
    handlePictureCardPreview4(file) {
      this.dialogImageUrl = file.url;
      this.ImageUrl = file.url;
      this.dialogVisibleImage = true;
    },
    handleRemove4(file, fileList, index) {
      if (this.utils.isNull(index)) {
        this.fileList = fileList;
        if (fileList.length == 0) {
          this.dataForm.business_license = "";
        } else {
          this.imgs = fileList
            .map(item => item.response.data.imgUrl)
            .toString();
          this.dataForm.business_license = this.imgs;
        }
      } else {
        this.business_license.splice(index, 1);
      }
    },
    //取消按钮
    cleanDataForm() {
      this.dialogVisible = false;
      this.dataForm = {
        name: "",
        address: "",
        type: "",
        pic: "",
        license_number: "",
        legal_name: "",
        legal_number: "",
        register_capital: "",
        scope: "",
        account_name: "",
        account_number: "",
        account_address: "",
        bail: "",
        bail_flag: "",
        mobile: "",
        pro_evaluate: "",
        server_evaluate: "",
        tms_evaluate: "",
        pro_industry: "",
        server_industry: "",
        tms_industry: "",
        status: "",
        withd_proport: "",
        service_range: "",
        id_card_z: "",
        id_card_f: "",
        food_safety: "",
        shop_address: "",
        contact_person: "",
        email: "",
        opentime: "",
        longitude: "",
        latitude: "",
        business_license: ""
      };
      this.$refs["shop_upload"].clearFiles();
      this.$refs["id_card_z_upload"].clearFiles();
      this.$refs["id_card_f_upload"].clearFiles();
      this.$refs["food_safety_upload"].clearFiles();
      this.$refs["business_license_upload"].clearFiles();
      this.shopImgList = [];
      this.idCardFImgList = [];
      this.idCardZImgList = [];
      this.businessLicenseImgList = [];
      this.foodSafetyImgList = [];
    },
    //库存设置
    setStock() {
      if (this.checked.length == 1) {
      } else {
        this.$message({ message: "请选择一条数据", type: "error" });
      }
    }
  },
  mounted() {
    this.initColumns();
    this.queryUserList();
  }
};
</script>

<style scoped>
/deep/ .el-input__inner   {
  width: 200px !important;
}
</style>